package com.wdd.owntool.ui.mvp

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.wdd.libbase.base.BaseMvpActivity
import com.wdd.owntool.R
import com.wdd.owntool.ui.mvp.presenter.MvpPresenter
import com.wdd.tools.mvp.contract.MvpContract
import kotlinx.android.synthetic.main.activity_mvp.*

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.owntool.ui.mvp
 * @ClassName:      MvpActivity
 * @Description:     java类作用描述
 * @Author:         王丹丹
 * @CreateDate:     2019/12/9 14:29
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/9 14:29
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
class MvpActivity : BaseMvpActivity<MvpPresenter>(), MvpContract.View {
    var manager: FragmentManager? = null

    override fun getLayoutId(): Int {
        return R.layout.activity_mvp
    }

    override fun initView() {
        manager = supportFragmentManager
        showFragment()
    }


    override fun initData() {
        mPresenter.obtainBaidu()

    }

    override fun showBaidu(content: String?) {
        text1.text = content
    }


    private fun showFragment() {

        val fragmentTransaction: FragmentTransaction = manager!!.beginTransaction()
        var fragment: Fragment? = MvpFragment()
        fragmentTransaction.add(R.id.fl, fragment!!, "fragment")
        fragmentTransaction.commitAllowingStateLoss()
        manager!!.executePendingTransactions()
    }
}